package com.wanmait.recruit.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.recruit.mapper.SkillLabelMapper;
import com.wanmait.recruit.pojo.SkillLabel;
import com.wanmait.recruit.service.SkillLabelService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("skillLabelService")
public class SkillLabelServiceImp implements SkillLabelService {
    @Resource
    private SkillLabelMapper skillLabelMapper;
    @Override
    public PageInfo<SkillLabel> findAllByName(String name, Integer pageNum) {
        int pageSize=10;
        PageHelper.startPage(pageNum,pageSize);
        List<SkillLabel> skillLabels = skillLabelMapper.findAllBySkillLabelName(name);
        PageInfo<SkillLabel> pageInfo = new PageInfo<>(skillLabels,11);
        return pageInfo;
    }

    @Override
    public void deleteById(Integer id) {
        skillLabelMapper.deleteById(id);
    }

    @Override
    public Boolean isRename(String name) {
        SkillLabel skillLabel = skillLabelMapper.findByname(name);
        if(skillLabel==null){
            return true;
        }
        else {
            return false;
        }
    }

    @Override
    public String findNameById(Integer skillLabelId) {
        SkillLabel skillLabel = skillLabelMapper.selectByPrimaryKey(skillLabelId);
        return skillLabel.getSkillLabelName();
    }

    @Override
    public List<SkillLabel> findAll() {
        return skillLabelMapper.findAll();
    }

    @Override
    public void insert(SkillLabel object) {
        skillLabelMapper.insert(object);
    }

    @Override
    public void delete(SkillLabel object) {

    }

    @Override
    public void update(SkillLabel object) {

    }

    @Override
    public PageInfo<SkillLabel> search(int pageNum, int pageSize) {
        return null;
    }
}
